﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media.Imaging;
using Mogubang_Sl.Core;

namespace Mogubang_Sl.Pages
{
    public partial class GuidePage : PhoneApplicationPage
    {
        int currIndex = 0;

        public GuidePage()
        {
            InitializeComponent();
        }

        private void btnReturn_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SoundManager.PlayEffect(SoundManager.clickbutton);
            if (this.NavigationService.CanGoBack)
            {
                this.NavigationService.GoBack();
            }
            else
            {
                this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }

        private void btnNext_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SoundManager.PlayEffect(SoundManager.clickbutton);
            currIndex++;
            currIndex = currIndex % 2;
            UpdateHelpeImage();
        }

        private void UpdateHelpeImage()
        {
            string uri = "/Images/";

            switch (currIndex)
            {
                case 0:
                    uri += "help1.png";
                    break;
                case 1:
                    uri += "help2.png";
                    break;
            }

            BitmapImage bitmap = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));
            this.imgHelp.Source = bitmap;
        }

        private void btnPrevious_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SoundManager.PlayEffect(SoundManager.clickbutton);
            currIndex--;
            if (currIndex < 0)
            {
                currIndex = 1;
            }
            UpdateHelpeImage();
        }
    }
}